BatchManager.getBatch   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
import { CodeBoost } from '@/lib/CodeBoost';
2
3
export class BatchManager {
4
    public data: any[] = [];
5
6
    constructor(public filename: string, public codeboost: CodeBoost) {
7
        this.data = filename ? require(filename) : [];
8
    }
9
10
    protected getBoost(boostName: string) {
11
        return this.codeboost.getBoost(boostName);
12
    }
13
14
    public getBatch(boostName: string, size: number) {
15
        return this.getUsableDataset(boostName).slice(0, size);
16
    }
17
18
    public insertBatch(item: any) {
19
        this.data.push({ name: item });
20
    }
21
22
    public getUsableDataset(boostName: string) {
23
        return this.data.filter(repo => this.getBoost(boostName)?.canRunOnRepository(repo.name));
24
    }
25
}
26